package com.sz.dao;

import com.sz.pojo.RevExp;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface IRevExpDao extends BaseMapper<RevExp>{
    //增加 一条收支记录
    @Insert("insert into ffms.rev_exp (adder, money, type, date, describes) values (#{adder},#{money},#{type},#{date},#{describes})")
    int addRecord(RevExp revexp);

    //查询未删除的所有信息
    @Select("select id, adder, money, type, date, describes from ffms.rev_exp where deleted = 0 limit #{page},14")
    List<RevExp> queryAll2(int page);

    //查询删除的所有信息
    @Select("select id, adder, money, type, date, describes, deleted from ffms.rev_exp limit #{page},14")
    List<RevExp> queryAll0(int page);

    @Select("select id, adder, money, type, date, describes, deleted from ffms.rev_exp where adder like #{queryContent} or describes like #{queryContent} limit #{page},14")
    List<RevExp> querySome0(String queryContent,int page);

    //条件查询2
    @Select("select id, adder, money, type, date, describes from ffms.rev_exp where deleted = 0 and adder like #{queryContent} or describes like #{queryContent} limit #{page},14")
    List<RevExp> querySome2(String queryContent,int page);

    @Select("select id, adder, money, type, date, describes, deleted from ffms.rev_exp where id=#{id}")
    RevExp queryById(int id);

    @Update("update ffms.rev_exp set adder = #{adder}, money = #{money}, type = #{type}, date = #{date}, describes = #{describes} where id = #{id}")
    int updateById1(RevExp revExp);

    //获取所有的adder
    @Select("select distinct adder from ffms.rev_exp")
    List<RevExp> getAllAdder();

    //条件查询
    @Select("select id, adder, money, type, date, describes from ffms.rev_exp ${sql}")
    List<RevExp> getByChoose(@Param(value = "sql") String sql);
}
